home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Leser 15 / Amiga Plus Leser CD 15.iso / Tools / Development / yacas_alg / yacas_morphos / share / yacas / controlflow.rep / code.ys < prev   
Encoding:
Text File  |  2002-03-13  |  931 b   |  56 lines

  1.  
  2. /* Defining a For function */
  3. TemplateFunction("For",{start,predicate,increment,body})
  4. [
  5.   Eval(start);
  6.   While (Equals(Eval(predicate),True))
  7.   [
  8.     Eval(body);
  9.     Eval(increment);
  10.   ];
  11. ];
  12. UnFence("For",4);
  13. HoldArgNr("For",4,1);
  14. HoldArgNr("For",4,2);
  15. HoldArgNr("For",4,3);
  16. HoldArgNr("For",4,4);
  17.  
  18.  
  19.  
  20. TemplateFunction("ForEach",{item,list,body})
  21. [
  22.   Local(foreachtail);
  23.   MacroLocal(item);
  24.   Set(foreachtail,list);
  25.   While(Not(Equals(foreachtail,{})))
  26.   [
  27.      MacroSet(item,Head(foreachtail));
  28.      Eval(body);
  29.      Set(foreachtail,Tail(foreachtail));
  30.   ];
  31. ];
  32. UnFence("ForEach",3);
  33. HoldArgNr("ForEach",3,1);
  34. HoldArgNr("ForEach",3,3);
  35.  
  36.  
  37. Apply(_applyoper,_applyargs) <-- ApplyPure(applyoper,applyargs);
  38. UnFence("Apply",2);
  39.  
  40.  
  41. TemplateFunction("Until",{predicate,body})
  42. [
  43.   Eval(body);
  44.   While (Equals(Eval(predicate),False))
  45.   [
  46.     Eval(body);
  47.   ];
  48.   True;
  49. ];
  50. UnFence("Until",2);
  51. HoldArgNr("Until",2,1);
  52. HoldArgNr("Until",2,2);
  53.  
  54.  
  55.  
  56.